<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>																			
<%@ include file="/WEB-INF/view/jsp/base.jsp" %>																																			
<html lang="en">
<head>
<style>
	.width{width: 206px;}
	input{-moz-box-sizing: border-box; }
</style>
</head>																																												
<body class="wysihtml5-supported">																																							
	<div id="content">																																										
		<div class="container-fluid">																																							
			<div class="row-fluid">																																							
				<div class="span12">																																							
					<div class="widget-box">																																					
						<div class="widget-title">																																			
							<h5>表单</h5>																																							
						</div>																																									
						<div class="widget-content nopadding">																																
							<form id="sysParaForm" action="" method="post" class="form-horizontal">																					
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>系统编号 :</label>																															
												<input  primaryKey="true"  type="text" class="" name="systemId" placeholder="" size="32"  maxlength="32">
												<span class="error_msg" name="error_systemId"></span>
										</div>		
									</div>	
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>参数描述 :</label>																															
										    	<textarea type="text" class="" name="paraDesc" placeholder="" style="width:768px;" size="128"  maxlength="128"></textarea>
												<span class="error_msg" name="error_paraDesc"></span>
										</div>		
									</div>
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>参数键 :</label>																															
												<input  primaryKey="true"  type="text" class="" name="paraKey" placeholder="" size="32"  maxlength="32">
												<span class="error_msg" name="error_paraKey"></span>
										</div>		
							    		<div class="flex-item">	
											<label>参数值类型 :</label>																															
												<select   class="" name="paraValueType" placeholder=""   maxlength="10">
													<option value="1">Type1</option>
													<option value="2">Type2</option>
												</select>
												<span class="error_msg" name="error_paraValueType"></span>
										</div>		
									</div>	
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>参数值(字符串) :</label>																															
											  	<input  type="text" class="" style="text-align:right;width:480px;"  name="paraValueStr" value="0" placeholder="" size="40"  maxlength="40">
												<span class="error_msg" name="error_paraValueStr"></span>
										</div>		
									</div>
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>参数值(整型) :</label>																															
											  	<input  type="text" class="" style="text-align:right;width:264px;"  name="paraValueInt" value="0" placeholder="" size="22"  maxlength="22">
												<span class="error_msg" name="error_paraValueInt"></span>
										</div>		
							    		<div class="flex-item">	
											<label>参数值(浮点型) :</label>																															
											  	<input  type="text" class="moneyNum " style="text-align:right;width:264px;" name="paraValueFloat" value="0.00" placeholder="0.00" size="22"  maxlength="22">
												<span class="error_msg" name="error_paraValueFloat"></span>
										</div>		
									</div>	
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>启用日期 :</label>																															
											   	<input  type="text" class="date" name="beginDate" placeholder="" style="width:120px;" size="10"  maxlength="10">
												<span class="error_msg" name="error_beginDate"></span>
										</div>		
							    		<div class="flex-item">	
											<label>禁用日期 :</label>																															
											   	<input  type="text" class="date" name="endDate" placeholder="" style="width:120px;" size="10"  maxlength="10">
												<span class="error_msg" name="error_endDate"></span>
										</div>		
									</div>	
									<div class="flexbox">																																
							    		<div class="flex-item">	
											<label>有效标志 :</label>																															
												<select   class="" name="invalidFlag" placeholder=""   maxlength="2">
													<option value="0">N</option>
													<option value="1">Y</option>
												</select>
												<span class="error_msg" name="error_invalidFlag"></span>
										</div>		
								<div class="form-actions">																																	
									<button id="id_add" type="button" class="btn btn-success f-right"  style="float:right;margin-left:10px;" onclick="save()">保存</button>											 
 									<button id="id_cancel" type="button" class="btn btn-info f-right"  style="float:right;margin-left:10px;" onclick="cancle()">取消</button>	
								</div>																																							
							</form>																																								
						</div>																																									
					</div>																																										
				</div>																																											
			</div>																																												
		</div>																																													
	</div>		
																																												
	<script>																																													
	    var params = mainParam.param;   //接收传来的参数																																							
	    var _pageNum = "" ;  //接收list页面传来的当面页数																																				
		//初始化表单数据																																												
		$(document).ready(function(){																																							
			$('.date').datetimepicker({
				language:'zh-CN',
				format:'yyyy-mm-dd',
				minView:"month",
				initialDate:new Date(),
				autoclose:true,
				todayBtn:true
			});
			
			_pageNum = "${param.pageNum}" ;																																					
			if(!$.isEmptyObject(params)){																																						
				$("input[primaryKey='true']").attr("readonly","readonly");																												
				$("#id_cancel").css("display","block");
				$.ajax({																																										
					url:"<%=path%>/sysPara/get",																																			
				    data:params,																																						
				    type:"post",																																								
				    success:function(text){																																						
				    	if(text.success){																																						
				    		$("#sysParaForm").autofill(text.data);																															
				    	}																																										
				    }																																											
				});																																												
			}																																													
		});																																														
		//保存表单数据																																												
		function save(){																																										
			var _editType = null ;																																								
			if(!$.isEmptyObject(params)){																																						
				_editType = "edit";																																							
				$("#sysParaForm").prop("action","<%=path %>/sysPara/update");																					
			}else{																																												
				_editType = "add";																																							
				$("#sysParaForm").prop("action","<%=path %>/sysPara/add");																						
			}																																													
			//保存																																												
			$("#sysParaForm").ajaxSubmit(function(text){																															
				C.handleError($("#sysParaForm"),text.error);
				C.gritter(text.message);
			    if(text.success){																																								
			    	if(_editType == "edit"){																																					
			    		cancle(); //返回原页面																																			
			    	}else if(_editType == "add"){																																				
						var $form = $("#sysParaForm");
						toLoad("<%=path %>/sysPara/detail",$form.serialize());																																					
			    	}																																											
				}																																												
			});																																													
		}		
		
		
		//输入金额类型数据
		$(".moneyNum").keyup(function(){
			var reg=$(this).val().match(/\d+\.?\d{0,2}/);
			var txt = '';
			if(reg!=null){
				txt=reg[0];
			}
			$(this).val(txt);
		}).change(function(){
			$(this).keypress();
			var v=$(this).val();
			if(/\.$/.test(v)){
				$(this).val(v.substr(0,v.length-1));
			}
		})
		
																																														
	</script>																																													
</body>																																														
 </html>	    																																												

